
#ifndef ___AWOS_TIMEOUT_H_
#define ___AWOS_TIMEOUT_H_

/* ticks in one second */
int hz;


#ifndef NULL
#define NULL ((void*)0x0)
#endif

/* the max pending timeouts */
#define MAX_TIMEOUTS 10

/* the flags */
#define TIMEOUT_INIT    1  /* is the timeout initialized with timeout_set()? */
#define TIMEOUT_PENDING 2  /* is the timeout in the queue to be run? */
#define TIMEOUT_RAN     4  /* has the timeout been ran? */
/* TIMEOUT_PENDING and TIMEOUT_RAN must never be set at the same time */

struct timeout
{
	void (*callback)(void *);
	void *arg;
	int flags;
	unsigned int time;
};



/* put info into a struct timeout */
void timeout_set(struct timeout *info, void (*callback)(void *), void *arg);
/* schedule a timeout in hz time. For example, to schedule a timeout to
   run in 3 minutes, do timeout_add(info, 3 * 60 * hz);
*/
void timeout_add(struct timeout *info, unsigned time);
/* remove a timeout from the queue BEFORE IT HAS BEEN RUN */
void timeout_del(struct timeout *info);




/* don't run these */
void _do_timeouts(unsigned long long); 
/* initialize timeouts */
void _timeout_init(void);


#endif // #ifndef ___AWOS_TIMEOUT_H_

